package com.cyzy.utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class TokenUtil {

    private static String secret = "lzf";



    public static String createToken(String value) {

        long currTime = System.currentTimeMillis()+30*60*1000;

        Date expireDate=new Date(currTime);

        String token=JWT.create()
                .withAudience(value)  //明文加密
                .withExpiresAt(expireDate)
                .sign(Algorithm.HMAC256(secret)
                );
        return token;
    }

}
